<template>
  <div class="nurse-wrapper-v2">
    <div class="sub-banner">
      <!-- <img :src="`${staticPath}/img_hulidaojia@2x.png`" alt=""> -->
      <van-swipe
        vertical
        class="huli-wrapper"
        :autoplay="3000"
        :show-indicators="false"
      >
        <van-swipe-item
          v-for="(item, index) in bannerList.huli.poster"
          :key="index"
        >
          <img :src="item.picurl" alt="" srcset="" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="service-panel">
      <h3 class="service-title">服务分类</h3>
      <div class="entry-list">
        <van-grid :column-num="5" :border="false">
          <van-grid-item
            :icon="item.picurl"
            :text="item.name"
            v-for="(item, index) in entryList"
            :key="index"
            @click="handleFilter(item)"
          />
        </van-grid>
      </div>
    </div>

    <div class="service-item">
      <van-cell
        is-link
        value="更多"
        style="padding-left: 15px; padding-right: 15px"
      >
        <template #title>
          <div class="custom-title">
            <h3>服务项目</h3>
            /<span class="upper-letter">service items</span>
          </div>
        </template>
      </van-cell>
      <div
        class="items-wrapper"
        v-for="item in list"
        :key="item.id"
        @click="handleLink(item)"
      >
        <div class="pic-wrapper">
          <div class="pic-img">
            <van-swipe :autoplay="3000" v-if="item.picurl.length">
              <van-swipe-item v-for="(image, index) in item.picurl" :key="index">
                <img :src="image" style="width: 120px;height: 100px" />
              </van-swipe-item>
            </van-swipe>
            <img
              src="http://placehold.it/400x200?text=暂无图片"
              v-else
              alt=""
              style="height: 100px"
            />
          </div>
          <div class="thrunmb">
            <div class="left">
              <p class="title"><i></i>{{ item.name }}</p>
              <div class="flex-desc">
               适用人群：{{ item.abstract }}
              </div>
            </div>
            <div class="right">
              <em>￥</em>{{ item.price }}<em>元<i>/次</i></em> <em class="line-price">￥{{ item.lineation }}</em>
            </div>
          </div>
        </div>
      </div>

      <div class="fixed-bottom">
        <van-pagination
          v-model="currentPage"
          :page-count="totalPage"
          :items-per-page="20"
          @change="turnPage"
          mode="simple"
        />
      </div>
    </div>
    <foot-tab></foot-tab>
  </div>
</template>

<script>
import { nurseItemServer, serverClassicOption } from "@/service/server";
import footTab from "@/components/footerTab/index";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      currentPage: 1,
      pageSize: 20,
      totalPage: 0,
      staticPath: process.env.VUE_APP_STATIC_PATH,
      list: [],
      entryList: [],
    };
  },
  created() {
    let params = {
      pageNum: 1,
      expand: "comment",
    };
    this.queryList(params);
    this.getServerList();
  },
  computed: {
    ...mapGetters(["bannerList"]),
  },
  methods: {
    handleFilter(item) {
      let params = {
        pageNum: 1,
        expand: "comment",
        type: item.id,
      };
      this.queryList(params);
    },
    handleLink(item) {
      this.$router.push({
        path: `/huli/detail/${item.id}`,
      });
    },
    turnPage(e) {
      this.currentPage = e;
      let params = {
        pageNum: this.currentPage,
        expand: "comment",
      };
      this.queryList(params);
    },
    async getServerList() {
      let result = await serverClassicOption();
      if (result.status == 200) {
        this.entryList = result.data;
      } else {
        this.$toast(result.message);
      }
    },
    async queryList(params) {
      let result = await nurseItemServer(params);
      if (result.status == 200) {
        this.list = result.data.model;
        this.pageSize = result.data._meta.totalCount;
        this.currentPage = result.data._meta.pageCount;
      } else {
        this.$toast(result.message);
      }
    },
  },
  components: {
    footTab,
  },
};
</script>

<style lang="less">
@import "~@/assets/less/mixin.less";
.fixed-bottom {
  width: 100%;
  // position: fixed;
  bottom: 70px;
  padding: 10px;
  padding-bottom: 60px;
}
.sub-banner {
  width: 100%;
  height: 150px;
}
img {
  width: 100%;
}
.nurse-wrapper-v2 {
  background: #f5f5f5;

  .service-panel {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    position: relative;
    z-index: 1;
    margin-top: -10px;
    padding: 15px;
    background: #f8f8f8;
    .service-title {
      font-size: 16px;
      color: #000;
      padding: 0 10px;
    }
  }
  .service-item {
    margin-top: 10px;
    background: #fff;
    
    .custom-title {
      display: flex;
      justify-content: flex-start;
      font-size: 16px;
      color: #000;
    }
    .van-cell__value {
      font-size: 13px;
      flex: none;
    }
  }
  .van-grid-item__content,
  .van-cell {
    background: #f8f8f8;
    padding-left: 0;
    padding-right: 0;
  }
  .line-price{
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
  }
  .items-wrapper {
    padding: 12px 15px;
    position: relative;
    &::after{
      content: '';
      position: absolute;
      box-sizing: border-box;
      pointer-events: none;
      right: 16px;
      bottom: 0;
      left: 16px;
      border-bottom: 1px solid #ebedf0;
      -webkit-transform: scaleY(0.5);
      transform: scaleY(0.5);
    }
    .pic-wrapper {
      // background: #f8f8f8;
      border-radius: 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .pic-img{
        width: 120px;
        min-height: 60px;
        img{
          width: 120px;
          height: 100px!important;
        }
      }
    }

    .thrunmb {
      flex: 1;
      display: flex;
      justify-content: space-around;
      align-items: flex-start;
      flex-direction: column;
      padding: 0 10px;
      height: 100px;
      .left {
        flex: 1;
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        flex-direction: column;
        .title {
          font-size: 16px;
          color: #000;
          .ellipsisLine(1);
        }
        .flex-desc {
          padding-top: 6px;
          height: 25px;
          line-height: 25px;
          color: #999;
          .ellipsisLine(1);
        }
      }
      .right {
        color: #e02e2e;
        font-size: 18px;
        i {
          font-size: 13px;
        }
      }
    }
  }
}
</style>